namespace EFS.Common.Values
{
	public class DateTime : EFS.Common.Values.Generic.Value<System.DateTime>
	{
		/// Implicit constructor
		public DateTime()
		{
		}

		/// Explicit constructor
		public DateTime(System.DateTime dateTime)
			: base(dateTime)
		{
		}

		// Set as string
		public override void SetString(System.String valueAsString)
		{
			if (EFS.Common.Verify.String(valueAsString))
			{
				InnerValue = System.DateTime.ParseExact(valueAsString,
					new System.String[] { "yyyy-MM-dd HH:mm:ss.fff" },
					new System.Globalization.CultureInfo("en-GB"),
					System.Globalization.DateTimeStyles.None);
			}
		}

		// To String
		public override string ToString()
		{
			// check null
			if (!IsNull)
			{
				return InnerValue.ToString("yyyy-MM-dd HH:mm:ss.fff");
			}

			// empty
			return "";
		}
	}
}